package com.xxrl.shop.domain;


import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.Proxy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author mis
 */
@ApiModel(description = "Address information of user.")
@Data
@NoArgsConstructor
@Entity
@Proxy(lazy = false)
@Table(name = "sp_address")
@EntityListeners(AuditingEntityListener.class)
public class Address implements Serializable {
    @ApiModelProperty(notes = "Unique identifier of the Address.", example = "1", required = true)
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    @ToString.Exclude
    @EqualsAndHashCode.Exclude
    @JsonIgnore
    @JSONField(serialize = false)
    private User user;

    @ApiModelProperty(notes = "Receiver name", example = "xxrl")
    private String receiver;
    @ApiModelProperty(notes = "Local street name", example = "st.emp")
    private String streetName;
    @ApiModelProperty(notes = "Phone number", example = "18099999999")
    private String phone;
    @ApiModelProperty(notes = "Is default address of user.", example = "true")
    private Boolean isDefault;

    @CreatedDate
    private Long createTime;

    @LastModifiedDate
    private Long lastModifiedTime;

    public Address(Long id) {
        this.id = id;
    }
}
